// pages/fukuan/fukuan.js
//获取应用实例
const app = getApp()
const api = require('../../../api/index.js');
Page({

  /**
   * 页面的初始数据
   */
  data: {
    display:"none"

  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    console.log(options)
    var data = options
    var that = this
    api.bookingDetails(data, (res) => {
      console.log(res, "这是调用订单详情返回的数据")
      that.setData({
        result:res.data.result
      })
    })
  },

  quxiao:function(){
    this.setData({
      display:"block"
    })
  },

  hideview:function(){
    this.setData({
      display: "none"
    })
  },

  phoneCall:function(res){
    var data = {
      subject_id: this.data.result.id
    }
    api.reservation(data, (res) => {
      console.log(res, "这是调用取消订单返回的数据")
      if (res.data.code == 200) {
        wx.navigateBack({
          delta:1
        })
      }
    })
  },

  fukuan:function(){
    var that = this
    var openid_wechat = wx.getStorageSync("openid")
    var data = {
      type: 1,
      order_sn: that.data.result.oreder_sn,
      e_id: that.data.result.s_id,
      num: that.data.result.num,
      is_vip_day: that.data.result.is_vip_day,
      openid_wechat: openid_wechat.openid
    }
    console.log(data, "这是调用付款接口要传的参数")
    api.orderwe(data, (res) => {
      console.log(res, "这是调用付款接口返回的数据")
      wx.requestPayment({
        timeStamp: res.data.result.timeStamp,
        nonceStr: res.data.result.nonceStr,
        package: res.data.result.package,
        signType: res.data.result.signType,
        paySign: res.data.result.paySign,
        success(res) {
          console.log(res)
        },
        fail(res) {}
      })
    })
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})